package cn.tqfeiyang.springplus.framework.pagination;

import cn.tqfeiyang.springplus.framework.Constants;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;

@Data
public class PageSearch {

    private static final long serialVersionUID = 1569531322874458585L;

    @Schema(description = "页码，默认为 1", example = "1")
    private Integer pageNumber = Constants.PAGE_DEFAULT_INDEX;

    @Schema(description = "页大小，默认为 10", example = "10")
    private Integer pageSize = Constants.PAGE_DEFAULT_SIZE;

    @Schema(description = "搜索关键字", example = "")
    private String searchKeyword = "";

    @Schema(description = "排序字段")
    private String orderBy = "";

    @Schema(description = "排序方式 asc：升序，desc：降序")
    private OrderDirection orderDirection = null;

    public Integer getPageNumber() {
        if (pageNumber == null || pageNumber <= 0) {
            pageNumber = Constants.PAGE_DEFAULT_INDEX;
        }
        return pageNumber;
    }

    public Integer getPageSize() {
        if (pageSize == null || pageSize <= 0) {
            pageSize = Constants.PAGE_DEFAULT_SIZE;
        }
        return pageSize;
    }

}